<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
   <%@taglib prefix="s" uri="/struts-tags" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>我的极目</title>
<link href="/ssh/css/forword.css" type="text/css" rel="stylesheet"><!-- 基于网页地址条寻址 非目录寻址 -->
<script type="text/javascript">
var xhr;
function checkPw(obj){
	  if(window.ActiveXObject){
		   //当IE为5以下
		   xhr = new ActiveXObject("Microsoft.XMLHTTP");
		  // alert("Microsoft.XMLHTTP类型");
	   }else if(window.XMLHttpRequest){
		   xhr = new XMLHttpRequest();
		   //alert("XMLHttpRequest类型");
		}else{
			//alert("浏览器不支持ajax技术!")
			return;
		}
	   //3.访问服务器端
	     xhr.onreadystatechange = callback;
		//3.2打开要访问的服务器资源
		//xhr.open("get","checkProdName.action?prodname=" + obj.value);
		//用post方法打开服务器端
		xhr.open("post","jchangePw.action");
		//3.3发送对服务器的访问请求
		xhr.setRequestHeader("If-Modified-Since","0");  //设置修改属性，消除IE缓存干扰
		xhr.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
		alert(obj.value);
		xhr.send("password=" + obj.value);
	   
}
function callback(){
	  // alert("回调函数");
	  //5.根据服务器返回结果处理客户端
	  //如果服务器端执行完毕
	  if(xhr.readyState == 4){
		  //如果结果wei执行成功
		  if(xhr.status == 200){
			  var ret = xhr.responseText;
			  if(ret.indexOf("yes") != -1){
				  var divObj = document.getElementById("pw");
				  divObj.innerHTML="密码输入错误，请重新输入！";
			  }else{
				  var divObj = document.getElementById("pw");
				  divObj.innerHTML="";
			  }
		  }else if(xhr.status == 404){
			  alert(404);
		  }
	  }
}
function checkSubmint(){
	  var divObj = document.getElementById("pw");
	  if(divObj.innerHTML){
		  return false;
	  }else{
		  return true;
	  }
}
 function checkPassword(){
	var password1 = document.getElementById("password1").value;
	var password2 = document.getElementById("password2").value;
	if(password1 != password2){
		var divObj = document.getElementById("chkPassword");
		  divObj.innerHTML="两次密码不一致，请从新输入";
	}else{
		  var divObj = document.getElementById("chkPassword");
		  divObj.innerHTML="";
	  }
}
</script>
</head>
<body>
<!-- 头部包含文件 -->
<%@include file="../commonq/myhead.jsp" %>
 <table class="main">
	<tr>
		<td style="width:200px;vertical-align:top;background:#D2D7D5;">
				<%@include file="../commonq/mymenu.jsp" %>	 
		</td>
		<td style="vertical-align:top;padding:20px">
		<div style="padding-left:20%;">
		<div style="text-align:left;height:30px;"><h3>修改密码：</h3></div>
			    <s:form action="modiUser.action" method="post">
			    <s:password label="输入改前密码" key="password" onblur="checkPw(this)"/>
			    <s:label id="pw" cssStyle="color:red;"></s:label>
			    <s:password label="输入修改后密码" name="user.password" id="password1"/>
			    <s:password label="再次输入修改后密码" name="password1" id="password2" onblur="checkPassword()"/>
			    <s:label id="chkPassword" cssStyle="color:red;"></s:label>
				<s:submit value="提交"/>
				<s:reset value="重置"/>
			</s:form>	
		</div>
		</td>
	</tr>
</table> 
 
<%@include file="../commonq/tail.jsp" %>
</body>
</html>